﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
//using System.Threading;

namespace PPSignSDKDemoForm
{
    public partial class MainWnd : Form
    {
        public MainWnd()
        {
            InitializeComponent();
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.comboBox_Device.SelectedIndex = 0;
        }

        private const Int32 MAX_PATH = 260;
        private bool m_bShow = false;
        private ImportDll.CallBackMyFun1 fun = null;

        private ImportDll.NOTIFYREALTIMESIGNDATA _RealDataCallback = null;

        ImportDll.DEVICE_TYPE_ID m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE;
        private IntPtr strBuf = IntPtr.Zero;
        private bool m_bEnableSaveVideo = true;
 
        private const Int32 L1000_SCREEN_WIDTH = 1280;
        private const Int32 L1000_SCREEN_HEIGHT = 800;
        L1000SignWndForm g_L1000SignWndForm = null;
        private Color m_clrOriginalDrawAreaBackColor;

        private void EnableBtn(bool bEnable)
        {
            if (bEnable)
            {
                L398InitBtn.Enabled = false;
                L398UnInitBtn.Enabled = true;
            }
            else
            {
                L398InitBtn.Enabled = true;
                L398UnInitBtn.Enabled = false;
            }

            SaveImageL398Btn.Enabled = bEnable;
            GetSizeL398Btn.Enabled = bEnable;
            //GetPointL398Btn.Enabled = bEnable;
            EncodeL398Btn.Enabled = bEnable;
            DecodeL398Btn.Enabled = bEnable;
            AboutL398Btn.Enabled = bEnable;
            GetDevInfL398Btn.Enabled = bEnable;
            SetClipL398Btn.Enabled = bEnable;
            combL398Image.Enabled = bEnable;
            combL398Color.Enabled = bEnable;
            combL398Style.Enabled = bEnable;
            //combL398GetPoint.Enabled = bEnable;
            combL398Encode.Enabled = bEnable;
            combL398DevInfo.Enabled = bEnable;
            ClearL398Btn.Enabled = bEnable;
            textClipX.Enabled = bEnable;
            textClipY.Enabled = bEnable;
            ColorL398lab.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            labelWidth.Enabled = bEnable;
            InputL398lab.Enabled = bEnable;
            textL398Status.Enabled = bEnable;
            comboBox_dpi.Enabled = bEnable;
            combWidth.Enabled = bEnable;
            textBoxfile.Text = "";

            SaveVideoBtn.Enabled = false;
            VideoFormatCB.Enabled = false;
            FPSCB.Enabled = false;
            EnableVideoBtn.Enabled = bEnable;

            if (bEnable)
                EnableVideoBtn.Text = "Enable";

            if ((m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE) ||
                (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE))
                PadIDL398Btn.Enabled = bEnable;

            if ((m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE) ||
                (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE) ||
                (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE))
            {
                RealTimeDataTextblock.Enabled = bEnable;
                RealTimeDataLabel.Enabled = bEnable;
            }

            if (bEnable)
            {
                textClipX.Text = "";
                textClipY.Text = "";
                combL398DevInfo.Items.Clear();
                combL398DevInfo.Items.Add("1"); combL398DevInfo.Items.Add("2");
                combL398DevInfo.Items.Add("3"); combL398DevInfo.Items.Add("4");
                combL398DevInfo.Items.Add("5"); combL398DevInfo.Items.Add("6");
                combL398DevInfo.Items.Add("7");
                combL398DevInfo.SelectedIndex = 0;

                combL398Image.Items.Clear();
                combL398Image.Items.Add("BMP");
                combL398Image.Items.Add("JPG");
                combL398Image.Items.Add("PNG");
                combL398Image.Items.Add("GIF");
                combL398Image.Items.Add("TIFF");
                combL398Image.Items.Add("PDF");
                combL398Image.Items.Add("SVG");
                combL398Image.SelectedIndex = 0;

                combL398Color.Items.Clear();
                combL398Color.Items.Add("Red");
                combL398Color.Items.Add("Green");
                combL398Color.Items.Add("Blue");
                combL398Color.Items.Add("Black");
                combL398Color.Items.Add("White");
                combL398Color.SelectedIndex = 3;

                combL398Style.Items.Clear();
                combL398Style.Items.Add("0 Pressure sensitivity");
                combL398Style.Items.Add("1 Fixed width");
                combL398Style.SelectedIndex = 0;

                combL398Encode.Items.Clear();
                combL398Encode.Items.Add("BMP");
                combL398Encode.Items.Add("JPG");
                combL398Encode.Items.Add("PNG");
                combL398Encode.Items.Add("GIF");
                combL398Encode.Items.Add("TIF");
                combL398Encode.Items.Add("INK");
                combL398Encode.SelectedIndex = 0;

                combWidth.Items.Clear();
                combWidth.Items.Add("1"); combWidth.Items.Add("2");
                combWidth.Items.Add("3"); combWidth.Items.Add("4");
                combWidth.Items.Add("5"); combWidth.Items.Add("6");
                combWidth.Items.Add("7"); combWidth.Items.Add("8");
                combWidth.Items.Add("9"); combWidth.Items.Add("10");
                combWidth.SelectedIndex = 2;

                comboBox_dpi.Items.Clear();
                comboBox_dpi.Items.Add("150 dpi");
                comboBox_dpi.Items.Add("300 dpi");
                comboBox_dpi.SelectedIndex = 0;


                VideoFormatCB.Items.Clear();
                VideoFormatCB.Items.Add("MP4");
                VideoFormatCB.Items.Add("WMV");
                VideoFormatCB.SelectedIndex = 0;

                FPSCB.Items.Clear();
                FPSCB.Items.Add("FPS(5)");
                FPSCB.Items.Add("FPS(10)");
                FPSCB.Items.Add("FPS(15)");
                FPSCB.Items.Add("FPS(20)");
                FPSCB.Items.Add("FPS(25)");
                FPSCB.Items.Add("FPS(30)");
                FPSCB.Items.Add("FPS(60)");
                FPSCB.Items.Add("FPS(90)");
                FPSCB.Items.Add("FPS(120)");
                FPSCB.Items.Add("FPS(150)");
                FPSCB.SelectedIndex = 5;
            }
        }

        private void L501FSetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPL501F_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }
        private void L398SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPL398_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void L500SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPL500_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void NatureSetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPNature_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void W300SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPW300_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void L1000SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPL1000_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void LC700SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPLC700_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void E640SetPenWidth()
        {
            UInt32 nItem = Convert.ToUInt32(combWidth.SelectedIndex) + 1;
            Int32 nVal = ImportDll.PPE640_SetPenWidth(m_deviceID, nItem);

            textL398Status.Text = nVal.ToString();
        }

        private void combWidth_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                L398SetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                NatureSetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                L500SetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                L501FSetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                W300SetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                L1000SetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                LC700SetPenWidth();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                E640SetPenWidth();
        }
 
        private void MainWnd_Load(object sender, EventArgs e)
        {
            this.Font = SystemFonts.DefaultFont;
            this.m_clrOriginalDrawAreaBackColor = this.panelDrawArea.BackColor;
        }

        /// <summary>
        /// L398
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        private void EnableL501FBtn(bool bEnable)
        {
            if (bEnable)
            {
                L398InitBtn.Enabled = false;
                L398UnInitBtn.Enabled = true;
            }
            else
            {
                L398InitBtn.Enabled = true;
                L398UnInitBtn.Enabled = false;
            }

            ClearL398Btn.Enabled = bEnable;
            SaveImageL398Btn.Enabled = bEnable;
            GetDevInfL398Btn.Enabled = bEnable;
            textL398Status.Enabled = bEnable;
            combL398Image.Enabled = bEnable;
            PadIDL398Btn.Enabled = bEnable;
            EncodeL398Btn.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            GetCertL398Btn.Enabled = bEnable;
            ReadCertL398Btn.Enabled = bEnable;
            PenIDL398Btn.Enabled = bEnable;
            GetSizeL398Btn.Enabled = bEnable;
            combL398Encode.Enabled = bEnable;
            combL398Style.Enabled = bEnable;
            combL398GetCert.Enabled = bEnable;
            combL398ReadCert.Enabled = bEnable;
            PadIDL398Btn.Enabled = bEnable;
            VersionL398Btn.Enabled = bEnable;
            GetPointL398Btn.Enabled = bEnable;
            DecodeL398Btn.Enabled = bEnable;
            DelFileL398Btn.Enabled = bEnable;
            SetClipL398Btn.Enabled = bEnable;
            VersionL398Btn.Enabled = bEnable;
            combL398GetPoint.Enabled = bEnable;
            combL398DelFile.Enabled = bEnable;
            combL398DevInfo.Enabled = bEnable;
            textClipX.Enabled = bEnable;
            textClipY.Enabled = bEnable;
            AboutL398Btn.Enabled = bEnable;
            ColorL398lab.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            InputL398lab.Enabled = bEnable;
            comboBox_dpi.Enabled = bEnable;
            panelDrawArea.Enabled = bEnable;
            labelWidth.Enabled = bEnable;
            //OpenLedL398Btn.Enabled = bEnable;
            //CloseLEDL398Btn.Enabled = bEnable;
            //ShowVerL398Btn.Enabled = bEnable;

            RealTimeDataTextblock.Enabled = bEnable;
            RealTimeDataLabel.Enabled = bEnable;

            SaveVideoBtn.Enabled = false;
            VideoFormatCB.Enabled = false;
            FPSCB.Enabled = false;
            EnableVideoBtn.Enabled = bEnable;

            if (bEnable)
                EnableVideoBtn.Text = "Enable";

            combWidth.Enabled = bEnable;
            textBoxfile.Text = "";

            if (bEnable)
            {
                combL398DevInfo.Items.Clear();
                combL398DevInfo.Items.Add("1"); combL398DevInfo.Items.Add("2");
                combL398DevInfo.Items.Add("3"); combL398DevInfo.Items.Add("4");
                combL398DevInfo.Items.Add("5"); combL398DevInfo.Items.Add("6");
                combL398DevInfo.Items.Add("7");
                combL398DevInfo.SelectedIndex = 0;

                combL398Image.Items.Clear();
                combL398Image.Items.Add("BMP");
                combL398Image.Items.Add("JPG");
                combL398Image.Items.Add("PNG");
                combL398Image.Items.Add("GIF");
                combL398Image.Items.Add("TIFF");
                combL398Image.Items.Add("PDF");
                combL398Image.Items.Add("SVG");
                combL398Image.SelectedIndex = 0;

                combL398Color.Items.Clear();
                combL398Color.Items.Add("Red");
                combL398Color.Items.Add("Green");
                combL398Color.Items.Add("Blue");
                combL398Color.Items.Add("Black");
                combL398Color.Items.Add("White");
                combL398Color.SelectedIndex = 3;

                combL398Style.Items.Clear();
                combL398Style.Items.Add("0 Pressure sensitivity");
                combL398Style.Items.Add("1 Fixed width");
                combL398Style.SelectedIndex = 0;

                combL398Encode.Items.Clear();
                combL398Encode.Items.Add("BMP");
                combL398Encode.Items.Add("JPG");
                combL398Encode.Items.Add("PNG");
                combL398Encode.Items.Add("GIF");
                combL398Encode.Items.Add("TIF");
                combL398Encode.Items.Add("INK");
                combL398Encode.SelectedIndex = 0;

                combL398ReadCert.Items.Clear();
                combL398ReadCert.Items.Add("1"); combL398ReadCert.Items.Add("2");
                combL398ReadCert.Items.Add("3"); combL398ReadCert.Items.Add("4");
                combL398ReadCert.Items.Add("5");
                combL398ReadCert.SelectedIndex = 0;

                combL398GetCert.Items.Clear();
                combL398GetCert.Items.Add("1"); combL398GetCert.Items.Add("2");
                combL398GetCert.Items.Add("3"); combL398GetCert.Items.Add("4");
                combL398GetCert.Items.Add("5");
                combL398GetCert.SelectedIndex = 0;

                combL398DelFile.Items.Clear();
                combL398DelFile.Items.Add("0"); combL398DelFile.Items.Add("1");
                combL398DelFile.Items.Add("2"); combL398DelFile.Items.Add("3");
                combL398DelFile.Items.Add("4"); combL398DelFile.Items.Add("5");
                combL398DelFile.SelectedIndex = 0;

                combWidth.Items.Clear();
                combWidth.Items.Add("1"); combWidth.Items.Add("2");
                combWidth.Items.Add("3"); combWidth.Items.Add("4");
                combWidth.Items.Add("5"); combWidth.Items.Add("6");
                combWidth.Items.Add("7"); combWidth.Items.Add("8");
                combWidth.Items.Add("9"); combWidth.Items.Add("10");
                combWidth.SelectedIndex = 2;

                comboBox_dpi.Items.Clear();
                comboBox_dpi.Items.Add("150 dpi");
                comboBox_dpi.Items.Add("300 dpi");
                comboBox_dpi.SelectedIndex = 0;

                VideoFormatCB.Items.Clear();
                VideoFormatCB.Items.Add("MP4");
                VideoFormatCB.Items.Add("WMV");
                VideoFormatCB.SelectedIndex = 0;

                FPSCB.Items.Clear();
                FPSCB.Items.Add("FPS(5)");
                FPSCB.Items.Add("FPS(10)");
                FPSCB.Items.Add("FPS(15)");
                FPSCB.Items.Add("FPS(20)");
                FPSCB.Items.Add("FPS(25)");
                FPSCB.Items.Add("FPS(30)");
                FPSCB.Items.Add("FPS(60)");
                FPSCB.Items.Add("FPS(90)");
                FPSCB.Items.Add("FPS(120)");
                FPSCB.Items.Add("FPS(150)");
                FPSCB.SelectedIndex = 5;
            }
        }

        private void EnableL398Btn(bool bEnable)
        {
            if (bEnable)
            {
                L398InitBtn.Enabled = false;
                L398UnInitBtn.Enabled = true;
            }
            else
            {
                L398InitBtn.Enabled = true;
                L398UnInitBtn.Enabled = false;
            }

            ClearL398Btn.Enabled = bEnable;
            SaveImageL398Btn.Enabled = bEnable;
            GetDevInfL398Btn.Enabled = bEnable;
            textL398Status.Enabled = bEnable;
            combL398Image.Enabled = bEnable;
            combL398Color.Enabled = bEnable;
            PadIDL398Btn.Enabled = bEnable;
            EncodeL398Btn.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            GetCertL398Btn.Enabled = bEnable;
            ReadCertL398Btn.Enabled = bEnable;
            PenIDL398Btn.Enabled = bEnable;
            GetSizeL398Btn.Enabled = bEnable;
            combL398Encode.Enabled = bEnable;
            combL398Style.Enabled = bEnable;
            combL398GetCert.Enabled = bEnable;
            combL398ReadCert.Enabled = bEnable;
            PadIDL398Btn.Enabled = bEnable;
            VersionL398Btn.Enabled = bEnable;
            GetPointL398Btn.Enabled = bEnable;
            DecodeL398Btn.Enabled = bEnable;
            DelFileL398Btn.Enabled = bEnable;
            SetClipL398Btn.Enabled = bEnable;
            VersionL398Btn.Enabled = bEnable;
            combL398GetPoint.Enabled = bEnable;
            combL398DelFile.Enabled = bEnable;
            combL398DevInfo.Enabled = bEnable;
            textClipX.Enabled = bEnable;
            textClipY.Enabled = bEnable;
            AboutL398Btn.Enabled = bEnable;
            ColorL398lab.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            InputL398lab.Enabled = bEnable;
            comboBox_dpi.Enabled = bEnable;
            panelDrawArea.Enabled = bEnable;
            labelWidth.Enabled = bEnable;
            OpenLedL398Btn.Enabled = bEnable;
            CloseLEDL398Btn.Enabled = bEnable;
            ShowVerL398Btn.Enabled = bEnable;

            RealTimeDataTextblock.Enabled = bEnable;
            RealTimeDataLabel.Enabled = bEnable;

            SaveVideoBtn.Enabled = false;
            VideoFormatCB.Enabled = false;
            FPSCB.Enabled = false;
            EnableVideoBtn.Enabled = bEnable;

            if (bEnable)
                EnableVideoBtn.Text = "Enable";

            combWidth.Enabled = bEnable;
            textBoxfile.Text = "";

            if (bEnable)
            {
                combL398DevInfo.Items.Clear();
                combL398DevInfo.Items.Add("1"); combL398DevInfo.Items.Add("2");
                combL398DevInfo.Items.Add("3"); combL398DevInfo.Items.Add("4");
                combL398DevInfo.Items.Add("5"); combL398DevInfo.Items.Add("6");
                combL398DevInfo.Items.Add("7");
                combL398DevInfo.SelectedIndex = 0;

                combL398Image.Items.Clear();
                combL398Image.Items.Add("BMP");
                combL398Image.Items.Add("JPG");
                combL398Image.Items.Add("PNG");
                combL398Image.Items.Add("GIF");
                combL398Image.Items.Add("TIFF");
                combL398Image.Items.Add("PDF");
                combL398Image.Items.Add("SVG");
                combL398Image.SelectedIndex = 0;

                combL398Color.Items.Clear();
                combL398Color.Items.Add("Black");
                combL398Color.Items.Add("Red");
                combL398Color.Items.Add("Green");
                combL398Color.Items.Add("Blue");
                combL398Color.Items.Add("Yellow");
                combL398Color.SelectedIndex = 0;

                combL398Style.Items.Clear();
                combL398Style.Items.Add("0 Pressure sensitivity");
                combL398Style.Items.Add("1 Fixed width");
                combL398Style.SelectedIndex = 0;
  
                combL398Encode.Items.Clear();
                combL398Encode.Items.Add("BMP");
                combL398Encode.Items.Add("JPG");
                combL398Encode.Items.Add("PNG");
                combL398Encode.Items.Add("GIF");
                combL398Encode.Items.Add("TIF");
                combL398Encode.Items.Add("INK");
                combL398Encode.SelectedIndex = 0;

                combL398ReadCert.Items.Clear();
                combL398ReadCert.Items.Add("1"); combL398ReadCert.Items.Add("2");
                combL398ReadCert.Items.Add("3"); combL398ReadCert.Items.Add("4");
                combL398ReadCert.Items.Add("5"); 
                combL398ReadCert.SelectedIndex = 0;

                combL398GetCert.Items.Clear();
                combL398GetCert.Items.Add("1"); combL398GetCert.Items.Add("2");
                combL398GetCert.Items.Add("3"); combL398GetCert.Items.Add("4");
                combL398GetCert.Items.Add("5");
                combL398GetCert.SelectedIndex = 0;

                combL398DelFile.Items.Clear();
                combL398DelFile.Items.Add("0"); combL398DelFile.Items.Add("1");
                combL398DelFile.Items.Add("2"); combL398DelFile.Items.Add("3");
                combL398DelFile.Items.Add("4"); combL398DelFile.Items.Add("5");
                combL398DelFile.SelectedIndex = 0;

                combWidth.Items.Clear();
                combWidth.Items.Add("1"); combWidth.Items.Add("2");
                combWidth.Items.Add("3"); combWidth.Items.Add("4");
                combWidth.Items.Add("5"); combWidth.Items.Add("6");
                combWidth.Items.Add("7"); combWidth.Items.Add("8");
                combWidth.Items.Add("9"); combWidth.Items.Add("10");
                combWidth.SelectedIndex = 2;

                comboBox_dpi.Items.Clear();
                comboBox_dpi.Items.Add("150 dpi");
                comboBox_dpi.Items.Add("300 dpi");
                comboBox_dpi.SelectedIndex = 0;

                VideoFormatCB.Items.Clear();
                VideoFormatCB.Items.Add("MP4");
                VideoFormatCB.Items.Add("WMV");
                VideoFormatCB.SelectedIndex = 0;

                FPSCB.Items.Clear();
                FPSCB.Items.Add("FPS(5)");
                FPSCB.Items.Add("FPS(10)");
                FPSCB.Items.Add("FPS(15)");
                FPSCB.Items.Add("FPS(20)");
                FPSCB.Items.Add("FPS(25)");
                FPSCB.Items.Add("FPS(30)");
                FPSCB.Items.Add("FPS(60)");
                FPSCB.Items.Add("FPS(90)");
                FPSCB.Items.Add("FPS(120)");
                FPSCB.Items.Add("FPS(150)");
                FPSCB.SelectedIndex = 5;
            }
        }

        private void EnableL1000Btn(bool bEnable)
        {
            if (bEnable)
            {
                L398InitBtn.Enabled = false;
                L398UnInitBtn.Enabled = true;
            }
            else
            {
                L398InitBtn.Enabled = true;
                L398UnInitBtn.Enabled = false;
            }

            SaveImageL398Btn.Enabled = bEnable;
            GetSizeL398Btn.Enabled = bEnable;
            //GetPointL398Btn.Enabled = bEnable;
            EncodeL398Btn.Enabled = bEnable;
            DecodeL398Btn.Enabled = bEnable;
            AboutL398Btn.Enabled = bEnable;
            GetDevInfL398Btn.Enabled = bEnable;
            SetClipL398Btn.Enabled = bEnable;
            combL398Image.Enabled = bEnable;
            //combL398Color.Enabled = bEnable;
            combL398Style.Enabled = bEnable;
            //combL398GetPoint.Enabled = bEnable;
            combL398Encode.Enabled = bEnable;
            combL398DevInfo.Enabled = bEnable;
            ClearL398Btn.Enabled = bEnable;
            textClipX.Enabled = bEnable;
            textClipY.Enabled = bEnable;
            ColorL398lab.Enabled = bEnable;
            StyleL398lab.Enabled = bEnable;
            labelWidth.Enabled = bEnable;
            InputL398lab.Enabled = bEnable;
            textL398Status.Enabled = bEnable;
            comboBox_dpi.Enabled = bEnable;
            combWidth.Enabled = bEnable;
            PadIDL398Btn.Enabled = bEnable;
            textBoxfile.Text = "";

            SaveVideoBtn.Enabled = false;
            VideoFormatCB.Enabled = false;
            FPSCB.Enabled = false;
            EnableVideoBtn.Enabled = bEnable;

            if (bEnable)
                EnableVideoBtn.Text = "Enable";

            //RealTimeDataTextblock.Enabled = bEnable;
            //RealTimeDataLabel.Enabled = bEnable;

            if (bEnable)
            {
                textClipX.Text = "";
                textClipY.Text = "";
                combL398DevInfo.Items.Clear();
                combL398DevInfo.Items.Add("1"); combL398DevInfo.Items.Add("2");
                combL398DevInfo.Items.Add("3"); combL398DevInfo.Items.Add("4");
                combL398DevInfo.Items.Add("5"); combL398DevInfo.Items.Add("6");
                combL398DevInfo.Items.Add("7");
                combL398DevInfo.SelectedIndex = 0;

                combL398Image.Items.Clear();
                combL398Image.Items.Add("BMP");
                combL398Image.Items.Add("JPG");
                combL398Image.Items.Add("PNG");
                combL398Image.Items.Add("GIF");
                combL398Image.Items.Add("TIFF");
                combL398Image.Items.Add("PDF");
                combL398Image.Items.Add("SVG");
                combL398Image.SelectedIndex = 0;

                combL398Color.Items.Clear();
                combL398Color.Items.Add("Red");
                combL398Color.Items.Add("Green");
                combL398Color.Items.Add("Blue");
                combL398Color.Items.Add("Black");
                combL398Color.Items.Add("White");
                combL398Color.SelectedIndex = 3;

                combL398Style.Items.Clear();
                combL398Style.Items.Add("0 Pressure sensitivity");
                combL398Style.Items.Add("1 Fixed width");
                combL398Style.SelectedIndex = 0;

                combL398Encode.Items.Clear();
                combL398Encode.Items.Add("BMP");
                combL398Encode.Items.Add("JPG");
                combL398Encode.Items.Add("PNG");
                combL398Encode.Items.Add("GIF");
                combL398Encode.Items.Add("TIF");
                combL398Encode.Items.Add("INK");
                combL398Encode.SelectedIndex = 0;

                combWidth.Items.Clear();
                combWidth.Items.Add("1"); combWidth.Items.Add("2");
                combWidth.Items.Add("3"); combWidth.Items.Add("4");
                combWidth.Items.Add("5"); combWidth.Items.Add("6");
                combWidth.Items.Add("7"); combWidth.Items.Add("8");
                combWidth.Items.Add("9"); combWidth.Items.Add("10");
                combWidth.SelectedIndex = 2;

                comboBox_dpi.Items.Clear();
                comboBox_dpi.Items.Add("150 dpi");
                comboBox_dpi.Items.Add("300 dpi");
                comboBox_dpi.SelectedIndex = 0;


                VideoFormatCB.Items.Clear();
                VideoFormatCB.Items.Add("MP4");
                VideoFormatCB.Items.Add("WMV");
                VideoFormatCB.SelectedIndex = 0;

                FPSCB.Items.Clear();
                FPSCB.Items.Add("FPS(5)");
                FPSCB.Items.Add("FPS(10)");
                FPSCB.Items.Add("FPS(15)");
                FPSCB.Items.Add("FPS(20)");
                FPSCB.Items.Add("FPS(25)");
                FPSCB.Items.Add("FPS(30)");
                FPSCB.Items.Add("FPS(60)");
                FPSCB.Items.Add("FPS(90)");
                FPSCB.Items.Add("FPS(120)");
                FPSCB.Items.Add("FPS(150)");
                FPSCB.SelectedIndex = 5;
            }
        }

        public void PPSignStatusNotify(Int32 nVal)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
            {
                switch (nVal)
                {
                    case (int)ImportDll.W300_HOTKEY.W300_CLEAN_KEY_CLICK:
                        textL398Status.Text = "Sign Canceled ! Clearing data, please wait...";
                        System.Windows.Forms.Application.DoEvents();
                        ImportDll.PPW300_Clear(m_deviceID);
                        textL398Status.Text = "You may start signing again !";
                        break;
                    case (int)ImportDll.W300_HOTKEY.W300_EXTRA_KEY_CLICK:
                        textL398Status.Text = "Extra Key Clicked !";
                        break;
                    case (int)ImportDll.W300_HOTKEY.W300_LEFT_KEY_CLICK:
                        textL398Status.Text = "Left Key Clicked !";
                        break;
                    case (int)ImportDll.W300_HOTKEY.W300_MIDDLE_KEY_CLICK:
                        textL398Status.Text = "Middle Key Clicked !";
                        break;
                    case (int)ImportDll.W300_HOTKEY.W300_RIGHT_KEY_CLICK:
                        textL398Status.Text = "Right Key Clicked !";
                        break;
                }
            }
            else
            {
                //  Form.CheckForIllegalCrossThreadCalls = false;
                if (nVal == 2)
                {
                    textL398Status.Text = "FingerPrint Image captured completed.";

                    if (g_L1000SignWndForm != null)
                    {
                        TextBox tbStatus = (TextBox)g_L1000SignWndForm.Controls.Find("L1000_tbStatus", true)[0];
                        tbStatus.Text = "FingerPrint Image captured completed.";
                    }
                    return;
                }
                else if (nVal == 1)
                {
                    //textL398Status.Text = "Sign OK .";
                    SaveDrawingImage();
                }
                else
                {
                    textL398Status.Text = "Sign Canceled ! Clearing data, please wait...";
                }

                System.Windows.Forms.Application.DoEvents();

                if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                    ImportDll.PPL398_Clear(m_deviceID);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                    ImportDll.PPL500_Clear(m_deviceID);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                    ImportDll.PPL501F_Clear(m_deviceID);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                    ImportDll.PPLC700_Clear(m_deviceID);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                    ImportDll.PPE640_Clear(m_deviceID);

                textL398Status.Text = "You may start signing again !";

            }
        }

        public static ushort LOWORD(uint value)
        {
            return (ushort)(value & 0xFFFF);
        }
        public static ushort HIWORD(uint value)
        {
            return (ushort)(value >> 16);
        }

        private void RealTimeDataCallback(IntPtr wParam, IntPtr lParam)
        {
            int wParamInt = wParam.ToInt32();
            int lParamInt = lParam.ToInt32();
            //decode real-time data...
            int nRealTimeX = (int)((LOWORD((uint)wParamInt)) / 65535.0 * panelDrawArea.Width);
            int nRealTimeY = (int)((HIWORD((uint)wParamInt)) / 65535.0 * panelDrawArea.Height);
            int nPressure = (int)LOWORD((uint)lParamInt);
            bool bPenDown = HIWORD((uint)lParamInt) == 0 ? false : true;

            if (bPenDown)
            {
                RealTimeDataTextblock.Text = "(" + nRealTimeX + "," + nRealTimeY + "," + nPressure + "," + "pen-down)";
            }
            else
            {
                RealTimeDataTextblock.Text = "(" + nRealTimeX + "," + nRealTimeY + "," + nPressure + "," + "pen-up)";
            }
        }


        private void InitialNatureDevice()
        {
            panelDrawArea.Show();
            IntPtr handle = ImportDll.PPNature_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, panelDrawArea.Handle);
            if (handle.ToInt32() < 0)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            ImportDll.PPNature_SetCanvasSize(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, 0, 0, panelDrawArea.Width, panelDrawArea.Height);
            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE;
            EnableBtn(true);
        }

        private void InitialL398Device()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPL398_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, panelDrawArea.Handle,0,0,panelDrawArea.ClientSize.Width,panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            Int32 ret = ImportDll.PPL398_SignatureStatusCallback(m_deviceID, fun);
            long retlong = ImportDll.PPL398_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE;
            EnableL398Btn(true);
        }

        private void InitialL500Device()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPL500_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, panelDrawArea.Handle, 0, 0, panelDrawArea.ClientSize.Width, panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            Int32 ret = ImportDll.PPL500_SignatureStatusCallback(m_deviceID, fun);
            long retlong = ImportDll.PPL500_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE;
            EnableL398Btn(true);
        }

        private void InitialL501FDevice()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPL501F_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, panelDrawArea.Handle, 0, 0, panelDrawArea.ClientSize.Width, panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int nFPImageWidth = 135;
            int nFPImageHeight = 150;
            int x = (panelDrawArea.ClientSize.Width - nFPImageWidth) >> 1;
            int y = (panelDrawArea.ClientSize.Height - nFPImageHeight) >> 1;

            int nResult = ImportDll.PPL501F_SetDisplayedFPImageAt(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, panelDrawArea.Handle, x, y, nFPImageWidth, nFPImageHeight);
            if (nResult != 0)
            {
                string strError = "PPL501F_SetDisplayedFPImageAt(), error = " + nResult.ToString();
                MessageBox.Show(strError, "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);
            Int32 ret = ImportDll.PPL501F_SignatureStatusCallback(m_deviceID, fun);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            long retlong = ImportDll.PPL501F_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);
            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE;
            EnableL501FBtn(true);
        }

        private void InitialW300Device()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPW300_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, panelDrawArea.Handle, 0, 0, panelDrawArea.ClientSize.Width, panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            Int32 ret = ImportDll.PPW300_SignatureStatusCallback(m_deviceID, fun);
            long retlong = ImportDll.PPW300_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE;
            EnableBtn(true);
        }

        private void InitialL1000Device()
        {
            panelDrawArea.Show();
            
            bool result = CreateSignWndOnL1000Screen();
            Size DrawAreaSize = new System.Drawing.Size(1180, 620);

            if((result==true) && (g_L1000SignWndForm != null))
                result = ImportDll.PPL1000_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, g_L1000SignWndForm.Handle, 50, 20, DrawAreaSize.Width, DrawAreaSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int nFPImageWidth = 107;
            int nFPImageHeight = 150;
            int x = (DrawAreaSize.Width - nFPImageWidth) >> 1;
            int y = (DrawAreaSize.Height - nFPImageHeight) >> 1;

            int nResult = ImportDll.PPL1000_SetDisplayedFPImageAt(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, g_L1000SignWndForm.Handle, x, y, nFPImageWidth, nFPImageHeight);
            if (nResult != 0)
            {
			    if(nResult != (int)ImportDll.ERROR_ID.RET_PST_DEVICENOREADY)
			    {
                    string strError = "PPL1000_SetDisplayedFPImageAt(), error = " + nResult.ToString();
                    MessageBox.Show(strError, "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
 			    }
            }

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE;
            ImportDll.PPL1000_EnableMouse(m_deviceID, true);
            EnableL1000Btn(true);
            panelDrawArea.BackColor = Color.White;

            if (nResult == (int)ImportDll.ERROR_ID.RET_PST_DEVICENOREADY)
                textL398Status.Text = "No Finger Print Feature !";
            else
            {
                if (fun == null)
                    fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);
                Int32 ret = ImportDll.PPL1000_SignatureStatusCallback(m_deviceID, fun);

                int nMinimumScore = 20; // score range (1 ~ 255), 1 : easiest captured; 255 : hardest captured
                ret = ImportDll.PPL1000_SetCaptureFPImageThresholdValue(m_deviceID, nMinimumScore);
            }
        }

        private void InitialLC700Device()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPLC700_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, panelDrawArea.Handle, 0, 0, panelDrawArea.ClientSize.Width, panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            Int32 ret = ImportDll.PPLC700_SignatureStatusCallback(m_deviceID, fun);
            long retlong = ImportDll.PPLC700_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE;
            EnableBtn(true);
        }

        private void InitialE640Device()
        {
            panelDrawArea.Show();
            bool result = ImportDll.PPE640_InitialDevice(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, panelDrawArea.Handle, 0, 0, panelDrawArea.ClientSize.Width, panelDrawArea.ClientSize.Height);
            if (result == false)
            {
                MessageBox.Show(" No Device！", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (fun == null)
                fun = new ImportDll.CallBackMyFun1(PPSignStatusNotify);

            if (_RealDataCallback == null)
                _RealDataCallback = new ImportDll.NOTIFYREALTIMESIGNDATA(RealTimeDataCallback);

            Int32 ret = ImportDll.PPE640_SignatureStatusCallback(m_deviceID, fun);
            long retlong = ImportDll.PPE640_RealTimeSignatureDataCallback(m_deviceID, _RealDataCallback);

            m_deviceID = ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE;
            EnableBtn(true);
        }

        private void L398InitBtn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                InitialL398Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                InitialNatureDevice();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                InitialL500Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                InitialL501FDevice();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                InitialW300Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                InitialL1000Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                InitialLC700Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                InitialE640Device();

            m_bEnableSaveVideo = true;
        }

        private void UninitialNatureDevice()
        {
            ImportDll.PPNature_Clear(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE);
            ImportDll.PPNature_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE);
            EnableBtn(false);
        }

        private void UninitialL398Device()
        {
            ImportDll.PPL398_CloseLed(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            ImportDll.PPL398_Clear(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            ImportDll.PPL398_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            EnableL398Btn(false);
        }

        private void UninitialL500Device()
        {
            ImportDll.PPL500_CloseLed(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            ImportDll.PPL500_Clear(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            ImportDll.PPL500_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            EnableL398Btn(false);
        }

        private void L398UnInitBtn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                UninitialL398Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                UninitialNatureDevice();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                UninitialL500Device();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                ImportDll.PPL501F_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE);
                EnableL501FBtn(false);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
            {
                ImportDll.PPW300_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE);
                EnableBtn(false);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
            {
                if (g_L1000SignWndForm != null)
                {
                    g_L1000SignWndForm.Close();
                    g_L1000SignWndForm = null;
                }
                ImportDll.PPL1000_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE);
                EnableL1000Btn(false);
                panelDrawArea.Invalidate(null);
                panelDrawArea.BackColor = m_clrOriginalDrawAreaBackColor;
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
            {
                ImportDll.PPLC700_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE);
                EnableBtn(false);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
            {
                ImportDll.PPE640_UnInitialDevice(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE);
                EnableBtn(false);
            }

            m_bEnableSaveVideo = false;
            textL398Status.Text = "";
        }

        private void PadIDL398Btn_Click(object sender, EventArgs e)
        {
            StringBuilder strRes = new StringBuilder(ImportDll.PPL398_SIGN_API_PAD_ID_LENGTH);

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                    ImportDll.PPL500_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                ImportDll.PPL501F_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                ImportDll.PPL1000_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                ImportDll.PPLC700_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                ImportDll.PPE640_GetHWPadID(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, strRes);

            textL398Status.Text = strRes.ToString(0, ImportDll.PPL398_SIGN_API_PAD_ID_LENGTH);
        }

        private void PenIDL398Btn_Click(object sender, EventArgs e)
        {
            UInt32 nlen = 0;
            StringBuilder strRes = new StringBuilder(ImportDll.PPL398_SIGN_API_ID_BUFFER_LENGTH);

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_GetHWPenID(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, strRes, ImportDll.PPL398_SIGN_API_ID_BUFFER_LENGTH, ref nlen);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ImportDll.PPL500_GetHWPenID(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, strRes, ImportDll.PPL398_SIGN_API_ID_BUFFER_LENGTH, ref nlen);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                ImportDll.PPL501F_GetHWPenID(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, strRes, ImportDll.PPL398_SIGN_API_ID_BUFFER_LENGTH, ref nlen);
            }

            textL398Status.Text = strRes.ToString();
        }

        private void VersionL398Btn_Click(object sender, EventArgs e)
        {
            StringBuilder strRes = new StringBuilder();

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_GetHWVersionID(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ImportDll.PPL500_GetHWVersionID(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, strRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                ImportDll.PPL501F_GetHWVersionID(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, strRes);
            }

            textL398Status.Text = strRes.ToString();
        }

        private void ShowVerL398Btn_Click(object sender, EventArgs e)
        {
            m_bShow = !m_bShow;
            Int32 nRes = Convert.ToInt32(m_bShow);

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_DisplayHWVersion(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ImportDll.PPL500_DisplayHWVersion(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nRes);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                //no api
            }

            textL398Status.Text = "Show Version " + m_bShow.ToString();
        }

        private void ClearL398Btn_Click(object sender, EventArgs e)
        {
            textL398Status.Text = "Clearing data, please wait...";

            System.Windows.Forms.Application.DoEvents();

            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                nVal = ImportDll.PPNature_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                nVal = ImportDll.PPL501F_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                nVal = ImportDll.PPW300_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
            {
                panelDrawArea.Invalidate(null);
                nVal = ImportDll.PPL1000_Clear(m_deviceID);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                nVal = ImportDll.PPLC700_Clear(m_deviceID);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                nVal = ImportDll.PPE640_Clear(m_deviceID);

            textL398Status.Text = "Clear finished, result = " + nVal.ToString();
        }

        private void OpenLedL398Btn_Click(object sender, EventArgs e)
        {
            Int32 nRes = 0;

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nRes = ImportDll.PPL398_OpenLed(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nRes = ImportDll.PPL500_OpenLed(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                //no api
            }

            textL398Status.Text = nRes.ToString();
        }

        private void CloseLEDL398Btn_Click(object sender, EventArgs e)
        {
            Int32 nRes = 0;

            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nRes = ImportDll.PPL398_CloseLed(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nRes = ImportDll.PPL500_CloseLed(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                //no api
            }

            textL398Status.Text = nRes.ToString();
        }

        private void GetSizeL398Btn_Click(object sender, EventArgs e)
        {
            Int32 nRes = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nRes = ImportDll.PPL398_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                nRes = ImportDll.PPNature_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nRes = ImportDll.PPL500_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                nRes = ImportDll.PPL501F_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                nRes = ImportDll.PPW300_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                nRes = ImportDll.PPL1000_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                nRes = ImportDll.PPLC700_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                nRes = ImportDll.PPE640_GetTotalPacketsNumber(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE);

            textL398Status.Text = nRes.ToString();

            if (nRes > 0)
            {
                GetPointL398Btn.Enabled = true;
                combL398GetPoint.Enabled = true;
                combL398GetPoint.Items.Clear();
                for (int i = 0; i < nRes; i++)
                {
                    combL398GetPoint.Items.Add(Convert.ToSingle(i));
                }
                combL398GetPoint.SelectedIndex = 0;
            }
            else
            {
                GetPointL398Btn.Enabled = false;
                combL398GetPoint.Enabled = false;
                combL398GetPoint.Items.Clear();
            }
        }

        private void GetPointL398Btn_Click(object sender, EventArgs e)
        {
            if (combL398GetPoint.Items.Count == 0)
                return;

            Int32 nItem = combL398GetPoint.SelectedIndex;

            if (nItem < 0)
                nItem = 0;

            ImportDll.tagPACKETS pst = new ImportDll.tagPACKETS();

            pst.btn = nItem;
            Int32 ret = 0;
            IntPtr tmpBuf =IntPtr.Zero;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
            {
                ret = ImportDll.PPL398_getPackets(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, ref pst);
                tmpBuf = ImportDll.PPL398_GetInkPointTime(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
            {
                ret = ImportDll.PPNature_getPackets(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, ref pst);
                tmpBuf = ImportDll.PPNature_GetInkPointTime(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
            {
                ret = ImportDll.PPL500_getPackets(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, ref pst);
                tmpBuf = ImportDll.PPL500_GetInkPointTime(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                ret = ImportDll.PPL501F_getPackets(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, ref pst);
                tmpBuf = ImportDll.PPL501F_GetInkPointTime(m_deviceID, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
            {
                ret = ImportDll.PPW300_getPackets(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, ref pst);
                tmpBuf = ImportDll.PPW300_GetInkPointTime(m_deviceID, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
            {
                ret = ImportDll.PPL1000_getPackets(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, ref pst);
                tmpBuf = ImportDll.PPL1000_GetInkPointTime(m_deviceID, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
            {
                ret = ImportDll.PPLC700_getPackets(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, ref pst);
                tmpBuf = ImportDll.PPLC700_GetInkPointTime(m_deviceID, combL398GetPoint.SelectedIndex);
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
            {
                ret = ImportDll.PPE640_getPackets(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, ref pst);
                tmpBuf = ImportDll.PPE640_GetInkPointTime(m_deviceID, combL398GetPoint.SelectedIndex);
            }

            StringBuilder sb = new StringBuilder();
            string timeString = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(tmpBuf);
            if (ret == 0)
            {
                sb.AppendFormat("index={0},X={1},Y={2},pressure={3}, time = {4},End ={5}",
                    pst.btn, pst.X, pst.Y, pst.Press,timeString,pst.bStrokeEnd?1:0);
            }
            else
            {
                sb.AppendFormat("code: {0} ", ret);
            }
            textL398Status.Text = sb.ToString();
            if (tmpBuf != IntPtr.Zero)
            {
                if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                    ImportDll.PPNature_FreeInkPointTime(m_deviceID,tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                    ImportDll.PPL398_FreeInkPointTime(m_deviceID,tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                    ImportDll.PPL500_FreeInkPointTime(m_deviceID, tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                    ImportDll.PPL501F_FreeInkPointTime(m_deviceID, tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                    ImportDll.PPW300_FreeInkPointTime(m_deviceID, tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                    ImportDll.PPL1000_FreeInkPointTime(m_deviceID, tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                    ImportDll.PPLC700_FreeInkPointTime(m_deviceID, tmpBuf);
                else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                    ImportDll.PPE640_FreeInkPointTime(m_deviceID, tmpBuf);
            }
        }

        private void EncodeNatureData()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPNature_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPNature_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeL398Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPL398_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPL398_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);
            textBoxfile.Text = str;
        }

        private void EncodeL500Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPL500_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPL500_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);
            textBoxfile.Text = str;
        }

        private void EncodeL501FData()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPL501F_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPL501F_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeW300Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPW300_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPW300_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeL1000Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPL1000_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPL1000_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeLC700Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPLC700_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPLC700_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeE640Data()
        {
            Int32 nItem = combL398Encode.SelectedIndex;
            nItem += 1;
            if (!strBuf.Equals(IntPtr.Zero))
            {
                ImportDll.PPE640_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
            }
            strBuf = ImportDll.PPE640_PacketsBase64Encode(m_deviceID, nItem);
            string str = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strBuf);

            textBoxfile.Text = str;
        }

        private void EncodeL398Btn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                EncodeL398Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                EncodeNatureData();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                EncodeL500Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                EncodeL501FData();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                EncodeW300Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                EncodeL1000Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                EncodeLC700Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                EncodeE640Data();
        }

        private void DecodeNatureData()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPNature_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPNature_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }
            Int32 number = ImportDll.PPNature_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPNature_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPNature_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPNature_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPNature_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeL398Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPL398_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPL398_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPL398_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();


            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPL398_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPL398_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPL398_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPL398_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeL500Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPL500_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPL500_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPL500_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPL500_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPL500_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPL500_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPL500_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeL501FData()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPL501F_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPL501F_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPL501F_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPL501F_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPL501F_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPL501F_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPL501F_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeW300Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPW300_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPW300_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPW300_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPW300_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPW300_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPW300_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPW300_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeL1000Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPL1000_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPL1000_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }
            Int32 number = ImportDll.PPL1000_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPL1000_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPL1000_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPL1000_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPL1000_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeLC700Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPLC700_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPLC700_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPLC700_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPLC700_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPLC700_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPLC700_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPLC700_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeE640Data()
        {
            if (strBuf == IntPtr.Zero)
                return;

            if (textBoxfile.Text.ToString() == "")
                return;
            SaveFileDialog dlg = new SaveFileDialog();
            UInt32 nItem = Convert.ToUInt32(combL398Encode.SelectedIndex);

            if (nItem == 0)
                dlg.Filter = "BMP文件|*.bmp";
            else if (nItem == 1)
                dlg.Filter = "JPG文件|*.jpg";
            else if (nItem == 2)
                dlg.Filter = "PNG文件|*.png";
            else if (nItem == 3)
                dlg.Filter = "GIF文件|*.gif";
            else if (nItem == 4)
                dlg.Filter = "TIFF文件|*.tiff";

            nItem = nItem + 1;
            if (nItem != 6)
            {
                dlg.AddExtension = true;
                dlg.FileName = "PPSignDecodeImage";
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
            }
            StringBuilder sbfile = new StringBuilder(dlg.FileName);
            StringBuilder sbcontent = new StringBuilder(textBoxfile.Text);

            ImportDll.PPE640_Base64Decode(m_deviceID, nItem, sbcontent, sbfile);

            if (nItem != 6)
            {
                ImportDll.PPE640_PacketsBase64EncodeFree(m_deviceID, strBuf);
                strBuf = IntPtr.Zero;
                return;
            }

            Int32 number = ImportDll.PPE640_GetTotalDecodePacketsNumber(m_deviceID);
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < number; i++)
            {
                Int32 X, Y, E;
                X = ImportDll.PPE640_GetDecodePacketsData(m_deviceID, i, 1);
                Y = ImportDll.PPE640_GetDecodePacketsData(m_deviceID, i, 2);
                E = ImportDll.PPE640_GetDecodePacketsData(m_deviceID, i, 3);

                sb.AppendFormat("index = {0}, X = {1}, Y = {2}, End = {3}\r\n", i, X, Y, E);
            }
            textBoxfile.Text = sb.ToString();

            ImportDll.PPE640_PacketsBase64EncodeFree(m_deviceID, strBuf);
            strBuf = IntPtr.Zero;
        }

        private void DecodeL398Btn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                DecodeL398Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                DecodeNatureData();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                DecodeL500Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                DecodeL501FData();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                DecodeW300Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                DecodeL1000Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                DecodeLC700Data();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                DecodeE640Data();
        }

        private void AboutL398Btn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                ImportDll.PPNature_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ImportDll.PPL500_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                ImportDll.PPL501F_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                ImportDll.PPW300_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                ImportDll.PPL1000_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                ImportDll.PPLC700_AboutBox();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                ImportDll.PPE640_AboutBox();
        }

        private void SaveDrawingImage()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Image.SelectedIndex);
            string strExt = ".bmp";
            if (nItem == 0)
                strExt = ".bmp";
            else if (nItem == 1)
                strExt = ".jpg";
            else if (nItem == 2)
                strExt = ".png";
            else if (nItem == 3)
                strExt = ".gif";
            else if (nItem == 4)
                strExt = ".tiff";
            else if (nItem == 5)
                strExt = ".pdf";
            else if (nItem == 6)
                strExt = ".svg";

            if (nItem >= 5)
                nItem++;

            string strName = DateTime.Now.ToString("yyyyMMddHHmmss") + strExt;

            //FolderBrowserDialog dlg = new FolderBrowserDialog();
            //dlg.SelectedPath = "c:";
            //dlg.Description = "请选择保存文件的目录";
            //if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            //    return;
            //string strFileName = dlg.SelectedPath + "\\";
            //strFileName += strName;

            string strFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + strName;
            StringBuilder sb = new StringBuilder(strFileName);

            Int32 index = comboBox_dpi.SelectedIndex;
            string dpi = comboBox_dpi.Items[index].ToString();
            int iDpi = index;

            Int32 ret = 0;
            nItem = nItem + 1;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ret = ImportDll.PPL398_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                ret = ImportDll.PPNature_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ret = ImportDll.PPL500_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                ret = ImportDll.PPL501F_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                ret = ImportDll.PPW300_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
            {
                string strDrawImagePath = strFileName;
                if (nItem == 7)
                {
                    strDrawImagePath = strDrawImagePath.Replace(".pdf", ".jpg");
                    StringBuilder sbDrawImagePath = new StringBuilder(strDrawImagePath);
                    ret = ImportDll.PPL1000_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, 2, sbDrawImagePath, iDpi);
                }
                else if (nItem == 8)
                {
                    strDrawImagePath = strDrawImagePath.Replace(".svg", ".jpg");
                    StringBuilder sbDrawImagePath = new StringBuilder(strDrawImagePath);
                    ret = ImportDll.PPL1000_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, 2, sbDrawImagePath, iDpi);
                }

                ret = ImportDll.PPL1000_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, sb, iDpi);

                Image imageSaved = Image.FromFile(strDrawImagePath);
                Graphics g = Graphics.FromHwnd(panelDrawArea.Handle);
                int nNewWidth = panelDrawArea.Width;
                int nNewHeight = (int)((float)nNewWidth * (float)imageSaved.Height / (float)imageSaved.Width);
                int nNewY = (panelDrawArea.Height - nNewHeight) >> 1;
                g.DrawImage(imageSaved, 0, nNewY, nNewWidth, nNewHeight);
                imageSaved.Dispose();
                g.Dispose();
            }
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                ret = ImportDll.PPLC700_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, sb, iDpi);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                ret = ImportDll.PPE640_SaveDrawingImage(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, sb, iDpi);

            textL398Status.Text = strFileName + ", result : " + ret;
        }

        private void SaveImageL398Btn_Click(object sender, EventArgs e)
        {
            SaveDrawingImage();
        }

        private void DelFileL398Btn_Click(object sender, EventArgs e)
        {
            Int32 nItem = combL398DelFile.SelectedIndex;

            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_ClearDeviceData(m_deviceID, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_ClearDeviceData(m_deviceID, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                nVal = ImportDll.PPL501F_ClearDeviceData(m_deviceID, nItem);
            }

            textL398Status.Text = "return=" + nVal.ToString();
        }

        private void GetCertL398Btn_Click(object sender, EventArgs e)
        {
            textL398Status.Text = "";
            Int32 nItem = combL398GetCert.SelectedIndex + 1;

            string str = System.Environment.CurrentDirectory;
            str = str + "\\";
            str = str + "sample.txt";
            StringBuilder filename = new StringBuilder(str);
            Int32 nClear = Convert.ToInt32(false);
            
            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_SaveDeviceData(m_deviceID, filename, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_SaveDeviceData(m_deviceID, filename, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                nVal = ImportDll.PPL501F_SaveDeviceData(m_deviceID, filename, nItem);
            }

            textL398Status.Text = "upload sample.txt into device, return=" + nVal.ToString();
        }

        private void ReadCertL398Btn_Click(object sender, EventArgs e)
        {
            textL398Status.Text = "";
            Int32 nItem = combL398ReadCert.SelectedIndex + 1;

            string strFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
            StringBuilder filename = new StringBuilder(strFileName);

            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_ReadDeviceData(m_deviceID, filename, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_ReadDeviceData(m_deviceID, filename, nItem);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
            {
                nVal = ImportDll.PPL501F_ReadDeviceData(m_deviceID, filename, nItem);
            }

            textL398Status.Text = "download device data to " + strFileName + ", return=" + nVal.ToString();

        }

        private void GetMouseDeviceInfo()
        {
            //Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            //switch (nItem)
            //{
            //    case ImportDll.HW_GET_STATUS:
            //        {
            //            IntPtr iStatus;
            //            ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
            //            if (iStatus.ToInt32() == 0)
            //                textL398Status.Text = "Device Connection : Successful";
            //            else
            //                textL398Status.Text = "Device Connection : Failed";
            //        }
            //        break;
            //    case ImportDll.HW_GET_AXIS_X:
            //        {
            //            ImportDll.tagPPAXIS iStatus;
            //            ImportDll.PPNature_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
            //            StringBuilder sb = new StringBuilder();
            //            sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
            //            textL398Status.Text = sb.ToString();
            //        }
            //        break;
            //    case ImportDll.HW_GET_AXIS_Y:
            //        {
            //            ImportDll.tagPPAXIS iStatus;
            //            ImportDll.PPNature_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
            //            StringBuilder sb = new StringBuilder();
            //            sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
            //            textL398Status.Text = sb.ToString();
            //        }
            //        break;
            //    case ImportDll.HW_GET_PRESSURE:
            //        {
            //            IntPtr iStatus;
            //            ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
            //            StringBuilder sb = new StringBuilder();
            //            sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
            //            textL398Status.Text = sb.ToString();
            //        }
            //        break;
            //    case ImportDll.HW_GET_VENDOR:
            //        {
            //            StringBuilder iStatus = new StringBuilder(MAX_PATH);
            //            ImportDll.PPNature_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, iStatus);

            //            textL398Status.Text = "Device Vendor: " + iStatus.ToString();
            //        }
            //        break;
            //    case ImportDll.HW_GET_PRODUCT:
            //        {
            //            StringBuilder iStatus = new StringBuilder(MAX_PATH);
            //            ImportDll.PPNature_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, iStatus);

            //            textL398Status.Text = "Device Name: " + iStatus.ToString();
            //        }
            //        break;
            //    case ImportDll.HW_GET_DRV_VER:
            //        {
            //            IntPtr iStatus;
            //            ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
            //            StringBuilder sb = new StringBuilder();
            //            Int32 uVersion = iStatus.ToInt32();
            //            sb.AppendFormat("{1}.{0}", (byte)(uVersion & 0xffff), (byte)((uVersion >> 16) & 0xffff));
            //            textL398Status.Text = sb.ToString();
            //        }
            //        break;
            //}
        }

        private void GetNatureDeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPNature_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPNature_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPNature_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPNature_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPNature_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (byte)(uVersion & 0xffff), (byte)((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetL398DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL398_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL398_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL398_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL398_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL398_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL398_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL398_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetL500DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL500_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL500_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL500_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL500_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL500_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL500_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name: " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL500_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetL501FDeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL501F_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL501F_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL501F_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL501F_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL501F_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL501F_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL501F_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetW300DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPW300_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPW300_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPW300_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPW300_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPW300_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPW300_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPW300_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetL1000DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL1000_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL1000_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPL1000_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL1000_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL1000_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPL1000_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPL1000_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetLC700DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPLC700_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPLC700_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPLC700_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPLC700_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPLC700_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPLC700_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPLC700_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetE640DeviceInfo()
        {
            Int32 nItem = combL398DevInfo.SelectedIndex + 1;
            switch (nItem)
            {
                case ImportDll.HW_GET_STATUS:
                    {
                        IntPtr iStatus;
                        ImportDll.PPE640_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, out iStatus);
                        if (iStatus.ToInt32() == 0)
                            textL398Status.Text = "Device Connection : Successful";
                        else
                            textL398Status.Text = "Device Connection : Failed";
                    }
                    break;
                case ImportDll.HW_GET_AXIS_X:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPE640_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device X Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_AXIS_Y:
                    {
                        ImportDll.tagPPAXIS iStatus;
                        ImportDll.PPE640_getDeviceInfoPPAXIS(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Y Range : {0} - {1}", iStatus.axMin, iStatus.axMax);
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRESSURE:
                    {
                        IntPtr iStatus;
                        ImportDll.PPE640_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        sb.AppendFormat("Device Pressure Range : {0} - {1}", 0, iStatus.ToInt32());
                        textL398Status.Text = sb.ToString();
                    }
                    break;
                case ImportDll.HW_GET_VENDOR:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPE640_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Vendor : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_PRODUCT:
                    {
                        StringBuilder iStatus = new StringBuilder(MAX_PATH);
                        ImportDll.PPE640_getDeviceInfoString(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, iStatus);

                        textL398Status.Text = "Device Name : " + iStatus.ToString();
                    }
                    break;
                case ImportDll.HW_GET_DRV_VER:
                    {
                        IntPtr iStatus;
                        ImportDll.PPE640_getDeviceInfo(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, out iStatus);
                        StringBuilder sb = new StringBuilder();
                        Int32 uVersion = iStatus.ToInt32();
                        sb.AppendFormat("{1}.{0}", (uVersion & 0xffff), ((uVersion >> 16) & 0xffff));
                        textL398Status.Text = sb.ToString();
                    }
                    break;
            }
        }

        private void GetDevInfL398Btn_Click(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                GetL398DeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                GetNatureDeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                GetL500DeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                GetL501FDeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                GetW300DeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                GetL1000DeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                GetLC700DeviceInfo();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                GetE640DeviceInfo();
        }

        private void combL398Encode_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBoxfile.Text = "";
        }

        private void SetNaturePenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPNature_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();  
        }

        private void SetL398PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPL398_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetL500PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPL500_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetL501FPenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPL501F_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetW300PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPW300_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetL1000PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPL1000_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetLC700PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPLC700_SetPenStyle(m_deviceID, nItem);

//            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void SetE640PenStyle()
        {
            UInt32 nItem = Convert.ToUInt32(combL398Style.SelectedIndex);
            Int32 nVal = ImportDll.PPE640_SetPenStyle(m_deviceID, nItem);

            //            combWidth.Enabled = false;
            textL398Status.Text = nVal.ToString();
        }

        private void combL398Style_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                SetL398PenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                SetNaturePenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                SetL500PenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                SetL501FPenStyle();
            else if(m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                SetW300PenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                SetL1000PenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                SetLC700PenStyle();
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                SetE640PenStyle();
        }

        private void SetPenColor()
        {
            UInt32 ulR = 0, ulG = 0, ulB = 0;
            //Int32 nItem = combL398Color.SelectedIndex;

            if (combL398Color.SelectedItem == null)
                return;

            string color = combL398Color.SelectedItem.ToString();
            if (color.CompareTo("Red") == 0)
            {
                ulR = 255;
            }
            else if (color.CompareTo("Green") == 0)
            {
                ulG = 255;
            }
            else if (color.CompareTo("Blue") == 0)
            {
                ulB = 255;
            }
            else if (color.CompareTo("Yellow") == 0)
            {
                ulR = 255;
                ulG = 255;
            }
            else if (color.CompareTo("White") == 0)
            {
                ulR = 255;
                ulG = 255;
                ulB = 255;
            }
            else
            {
                ulR = 0;
                ulG = 0;
                ulB = 0;
            }
            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                nVal = ImportDll.PPNature_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                nVal = ImportDll.PPL501F_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                nVal = ImportDll.PPW300_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                nVal = ImportDll.PPL1000_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                nVal = ImportDll.PPLC700_SetPenColor(m_deviceID, ulR, ulG, ulB);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                nVal = ImportDll.PPE640_SetPenColor(m_deviceID, ulR, ulG, ulB);

            textL398Status.Text = nVal.ToString();
        }

        private void combL398Color_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetPenColor();
        }

        static private System.Text.RegularExpressions.Regex rg = new System.Text.RegularExpressions.Regex("[^0-9]+");
        private void textClipX_TextChanged(object sender, EventArgs e)
        {
            int curr = this.textClipX.SelectionStart;
            this.textClipX.Text = rg.Replace(this.textClipX.Text, "");
            if (this.textClipX.SelectionStart == 0)
            {
                this.textClipX.SelectionStart = 0;
            }
            else
            {
                this.textClipX.SelectionStart = curr;
            } 
        }

        private void textClipY_TextChanged(object sender, EventArgs e)
        {
            int curr = this.textClipY.SelectionStart;
            this.textClipY.Text = rg.Replace(this.textClipY.Text, "");
            if (this.textClipY.SelectionStart == 0)
            {
                this.textClipY.SelectionStart = 0;
            }
            else
            {
                this.textClipY.SelectionStart = curr;
            }           
        }
//        private static string strfile = System.Environment.GetEnvironmentVariable("TEMP");
//        private static string strfilename = "\\PPSignTempImage.bmp";

        private void SetClipL398Btn_Click(object sender, EventArgs e)
        {
            string strX = textClipX.Text;
            string strY = textClipY.Text;
            UInt32 nClipX = 0;
            UInt32 nClipY = 0;

            if (strX != "")
                nClipX = Convert.ToUInt32(strX);
            if (strY != "")
                nClipY = Convert.ToUInt32(strY);
            if (nClipX < 0 || nClipY < 0)
            {
                MessageBox.Show("Input Clip X, Y should be positive value !", "PPSignSDKDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Int32 nTure = Convert.ToInt32(true);
            Int32 nVal = 0;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                nVal = ImportDll.PPL398_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                nVal = ImportDll.PPNature_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                nVal = ImportDll.PPL500_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                nVal = ImportDll.PPL501F_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                nVal = ImportDll.PPW300_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                nVal = ImportDll.PPL1000_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                nVal = ImportDll.PPLC700_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                nVal = ImportDll.PPE640_SetSaveCenterImageClip(m_deviceID, nTure, nClipX, nClipY);

            textL398Status.Text = nVal.ToString();
//            System.Threading.Thread.Sleep(50);

            //showImageDlg showdlg = new showImageDlg();
            //showdlg.Owner = this;
            //showdlg.StartPosition = FormStartPosition.CenterParent;
            //showdlg.ShowDialog();

//            string strSrc = strfile + strfilename;
//            if (File.Exists(strSrc))
//               File.Delete(strSrc);
        }

        private void CalL398Btn_Click(object sender, EventArgs e)
        {
            CalDlg dlg = new CalDlg();
            dlg.Owner = this;
            dlg.ShowDialog();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.L398UnInitBtn.PerformClick();/// L398UnInitBtn_Click(this, e);
            Close();
        }

        private void comboBox_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = comboBox_Device.SelectedIndex;
            string sDevice = comboBox_Device.Items[index].ToString ();
            if (sDevice.Equals ("L370/L398", StringComparison.OrdinalIgnoreCase) ||
                sDevice.Equals("E550/E560", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE;
            else if (sDevice.Equals ("Nature", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE;
            else if (sDevice.Equals("L500", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE;
            else if (sDevice.Equals("L501F/L501G", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE;
            else if (sDevice.Equals("W300", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE;
            else if (sDevice.Equals("L1000", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE;
            else if (sDevice.Equals("LC700", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE;
            else if (sDevice.Equals("E640", StringComparison.OrdinalIgnoreCase))
                m_deviceID = ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE;
        }

        private void comboBox_dpi_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void combL398DevInfo_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            UInt32 nItem = Convert.ToUInt32(VideoFormatCB.SelectedIndex);

            string strExt = ".mp4";
            if (nItem == 0)
                strExt = ".mp4";
            else if (nItem == 1)
                strExt = ".wmv";

            string strName = DateTime.Now.ToString("yyyyMMddHHmmss") + strExt;
            string strFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + strName;
            StringBuilder sb = new StringBuilder(strFileName);

            int index = FPSCB.SelectedIndex;
            int FPS = index + 1;// int.Parse(strDpi);

            Int32 ret = 0;
            nItem = nItem + 1;
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ret = ImportDll.PPL398_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                ret = ImportDll.PPNature_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ret = ImportDll.PPL500_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                ret = ImportDll.PPL501F_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                ret = ImportDll.PPW300_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                ret = ImportDll.PPL1000_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                ret = ImportDll.PPLC700_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, nItem, FPS, sb);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                ret = ImportDll.PPE640_SaveDrawingVideo(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, nItem, FPS, sb);

            System.Threading.Thread.Sleep(100);
            textL398Status.Text = strFileName + ", result : " + ret;
        }

        private void combL398Image_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void EnableVideoBtn_Click(object sender, EventArgs e)
        {
            ClearL398Btn.PerformClick();

	        if(m_bEnableSaveVideo)
	        {
                EnableVideoBtn.Text = "Disable";

                SaveVideoBtn.Enabled = true;
                VideoFormatCB.Enabled = true;
                FPSCB.Enabled = true;

		        SaveDrawingVideoAction(true);
	        }
	        else
	        {
                EnableVideoBtn.Text = "Enable";

                SaveVideoBtn.Enabled = false;
                VideoFormatCB.Enabled = false;
                FPSCB.Enabled = false;

		        SaveDrawingVideoAction(false);
	        }

	        m_bEnableSaveVideo = !m_bEnableSaveVideo;
        }

        private void SaveDrawingVideoAction(bool bEnable)
        {
            if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE)
                ImportDll.PPL398_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPL398_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE)
                ImportDll.PPNature_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPNature_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE)
                ImportDll.PPL500_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPL500_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE)
                ImportDll.PPL501F_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPL501F_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE)
                ImportDll.PPW300_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPW300_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE)
                ImportDll.PPL1000_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPL1000_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE)
                ImportDll.PPLC700_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPLC700_DEVICE, bEnable);
            else if (m_deviceID == ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE)
                ImportDll.PPE640_EnableSaveVideoData(ImportDll.DEVICE_TYPE_ID.PPE640_DEVICE, bEnable);
        }

        private bool CreateSignWndOnL1000Screen()
        {
            bool result = false;

            foreach (Screen currentScr in Screen.AllScreens)
            {
                if ((currentScr.Bounds.Width == L1000_SCREEN_WIDTH) &&
                    (currentScr.Bounds.Height == L1000_SCREEN_HEIGHT))
                {
                    // create L1000 SignWnd Form...
                    g_L1000SignWndForm = new L1000SignWndForm(this);
                    if (g_L1000SignWndForm != null)
                    {
                        g_L1000SignWndForm.StartPosition = FormStartPosition.Manual;
                        g_L1000SignWndForm.Location = new Point(currentScr.Bounds.Left, currentScr.Bounds.Top);
                        g_L1000SignWndForm.Width = L1000_SCREEN_WIDTH;
                        g_L1000SignWndForm.Height = L1000_SCREEN_HEIGHT;
                        g_L1000SignWndForm.Show();
                        result = true;
                    }
                    break;
                }
            }

            return result;
        }
    }
}
